#include "Interactiv_BIM/Interactiv_BIMPublic.h"

//
bool LabelCommand::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
	osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
	if (!view) return false;

	switch(ea.getEventType())
	{
	case(osgGA::GUIEventAdapter::PUSH):
		{
			_mx = ea.getX();
			_my = ea.getY();

			if (ea.getButton() ==  osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON && state_ == 1)
			{
				CommandBegin(ea, aa);
			}
			break;
		}
	case(osgGA::GUIEventAdapter::RELEASE) : 
		{
			if (ea.getButton() ==  osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON && state_ == 2)
			{
				CommandEnd(ea, aa);
			}
			else if (_mx==ea.getX() && _my==ea.getY() && state_ == 2)
			{
				CommandExe(ea, aa);
			}

			break;
		}
	default:
		break;
	}
	return false;
}

LabelCommand::LabelCommand(InteractivBIM* bim_Interactiv, int type) : ChaiDanCommand(bim_Interactiv, type)
{
	state_ = 1;
}

void LabelCommand::CommandBegin(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
	//bim_Interactiv_->BeginAddMark();
	state_ = 2;
}

void LabelCommand::CommandEnd(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
	//Command::CommandEnd(ea, aa) ;

	//bim_Interactiv_->SaveMarks();
	//state_ = 0;
}

void LabelCommand::CommandExe(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)  
{
	//bim_Interactiv_->AddMarks(ea);
}
